package com.sfy.user.controller;


import com.sfy.common.dto.InstructorDTO;
import com.sfy.user.dataObject.Instructor;
import com.sfy.user.msmapper.MsInstructorMapper;
import com.sfy.user.service.InstructorService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/instructors")
public class InstructorController {

    private final InstructorService instructorService;
    private final MsInstructorMapper instructorMapper;
    @GetMapping("/{instructorId}")
    public ResponseEntity<InstructorDTO> getInstructorById(@PathVariable Integer instructorId) {
        Instructor instructor = instructorService.getById(instructorId);
        if (instructor == null) {
            return ResponseEntity.notFound().build();
        }
        InstructorDTO instructorDTO = instructorMapper.toInstructorDTO(instructor);
        return ResponseEntity.ok(instructorDTO);
    }
}
